home *** CD-ROM | disk | FTP | other *** search
/ CICA 1993 April / CICA MS Windows - April 1993.iso / unzipped / programr / vbasic / vbprimer / vb.le_ / vb.bin (.txt)
Microsoft Lesson  |  1992-12-15  |  214KB  |  1,617 lines

  1. Out of Memory xxx
  2. File Missing
  3. Unrecognized Error
  4. Microsoft CBT
  5. &Instructions
  6. &Back
  7. &Menu
  8. &Summary
  9. E&xit Tutorial
  10. Cancel: Esc
  11. Options
  12. dding Menus5
  13. A.How to Use the Learning Visual Basic Tutorial 
  14. Opens this window.-
  15. Jumps to the SummaryA
  16. for that lesson.
  17. Returns to the Menu.t
  18. )Click a lesson name to start that lesson.
  19. (To learn how to use the tutorial, click A
  20. the Instructions button.!
  21. Closes the Options A
  22. menu.X
  23. +When you're done reading the Instructions, A$click the Close Instructions button.8
  24. Closes the tutorial andA
  25. returns to Visual Basic.s
  26. )Click a lesson name to start that lesson.
  27. 'To learn how to use the tutorial, clickA
  28. the Instructions button.;
  29. To go forward in a lesson,A
  30. click the Next button.  $
  31. reating an Application#
  32. ow Visual Basic Works&
  33. Learning Microsoft Visual Basic%
  34. sing Color and Graphics%
  35. Returns to theA
  36. previous step.
  37. Options<
  38. To go backward in a lesson,A
  39. click the Back button.  +
  40. riting Event-DrivenB
  41. Programs5
  42. A.How to Use the Learning Visual Basic Tutorial 
  43. nstructions
  44. Clicking the Options button 
  45. opens a menu of different 
  46. ways to get around in the 
  47. tutorial, as shown inA
  48. the diagram at right.&
  49. Learning Microsoft Visual Basic.
  50. A'Select a lesson or choose Instructions.j
  51. A red arrow  
  52. points to an instruction 
  53. 'for you to follow to continue with the A    tutorial.    &Options
  54. E&xit
  55. &Back
  56. &Instructions
  57. &Menu
  58.     &Summary
  59. E&xit Tutorial
  60. Cancel: Esc
  61. C&lose Instructions
  62. wwwwwwwwwwwwwwwwwww
  63. wwwwwwwwwwwwwwwwwww
  64. wwwwwww
  65. wwwxw
  66. wwwwwwwwwwwwwwwwwww
  67. wwwwwwwwwwwwwwwwwww
  68. wwwwwww
  69. wwwww
  70. UUUUUUUUUUUWx
  71. UUUUUUUUUUUWw
  72. UUUUUUUUUUUUx
  73. wwwwwwwwwwwwwwwwwww
  74. wwwwwwwwwwwwwwwwwww
  75. wwwwwwwwwwwwwww
  76. wwwwwww
  77. UUUUUUUUUUUU
  78. UUUUUUUUUUUU
  79. wwwwwwwwwwwwwwwwwww
  80. wwwwwwwwwwwwwwwwwww
  81. wwwwwwwww
  82. UUUUUUUUUUUUUU
  83. wwwwwwwwwwwwwwwwwww
  84. wwwwwwwwwwwwwwwwwww
  85. UUUUUUUU
  86. UUUUUUUUPf`
  87. UUUUUUUP
  88. Pwwwwwwww
  89. wwwwwp
  90. UUUPP
  91. wwwwwwwwwwwwwwwwwww
  92. wwwwwwwwwwwwwwwwwww
  93. UUUUP
  94. UUUUP
  95.     Form1.frmA
  96. Countries of the World
  97. Summary:,
  98. ile    
  99. dit    
  100. ountry
  101. Guinea
  102. Population
  103. GRID.VBXA
  104. $2,400 Million
  105. (This lesson introduced you to the Visual
  106. Basic design environment. 
  107. .In the following lessons, you'll learn how to @(use Visual Basic to create applications.
  108. Income per Capita
  109. $330.17
  110. OLECLIEN.VBXA
  111. Form1
  112. Form1B
  113. Form1
  114. Form2.
  115. ile     
  116. dit     
  117. ountry
  118. Next Country
  119. Next Country:
  120. Invalid Country
  121. Label1
  122. <To help you review your code quickly, Visual Basic provides:
  123. Automatic syntax checking
  124. Debugging tools
  125. A Debug window
  126. A    cmdCancel
  127. Text1
  128. %Visual Basic includes an easy-to-use 
  129. language
  130.  that is compatible with
  131. HVisual Basic for MS-DOS, QBasic, Basic Compiler 7.1, and other Microsoft@+Basic products.  Language features include:    
  132. Form1 B
  133. Form:
  134. You use the 
  135. Toolbox to draw
  136. controls on aA
  137. form.F
  138. cmdCancel_Click 
  139.    NextCountry.
  140. HideA
  141. End Sub
  142. AutoRedraw
  143. A    BackColor
  144. BorderStyle
  145. Form1
  146. As a dialog box
  147. ClipControls
  148. Property)
  149. Step through linesA
  150. or procedures.
  151. ControlBox)
  152. A"Form1.ForeColor = RGB(0, 255, 255)
  153. DrawMode
  154. A    DrawStyle
  155. A    DrawWidth
  156. Enabled-
  157. Integer
  158. Single
  159. DoubleA
  160. Variant
  161. False
  162. &80000005&
  163. 2 - Sizable
  164. Caption
  165. 13 - Copy Pen
  166. A    0 - Solid
  167. Sweden
  168. ountry
  169. Controls
  170. C are tools such as boxes, buttons, and labels you draw on a form to
  171. Kget input or to display output.  They also add visual appeal to your forms.@
  172. You can choose 
  173. the View Form 
  174. button to display A
  175. a form.7
  176. .A module contains declarations and procedures.A
  177. Currency
  178. String
  179. Japan@
  180. Instead of crowding your formA
  181. with command buttons . . .
  182. dd Watch...
  183. ext Country=
  184. @:You design menus for your forms in the Menu Design window.
  185. Loops<
  186. Print 
  187. UCase(
  188. Country
  189. A"Numerous math and string functions
  190. tion:P
  191. Visual Basic displays a 
  192. message when it findsA
  193. an error in your syntax.
  194. (none)
  195. nstant Watch...
  196. alls...!
  197. ext Statement6
  198. Set or show the next statementA
  199. to be executed.M
  200.  Set and display watch variables.A$List active procedures during break.
  201. Manage breakpoints.T
  202. The Visual Basic language
  203.     Menu bars
  204. The Color palette
  205. hortcut:
  206. elpContextID:
  207. Visual Basic also provides a 
  208. Color palette
  209. ! with 48 standard colors you can @Iuse to add color to your forms.  Visual Basic supports 256-color systems._
  210. Set breakpoints, view Instant 
  211. Watch, display the Calls A
  212. window, or step through code.
  213. Population
  214. Canada
  215. Next Country
  216. <To help you review your code quickly, Visual Basic provides:
  217. Automatic syntax checking
  218. Debugging tools
  219. Microsoft Visual Basic
  220. Expected: =
  221. Debug Window[Form1]H
  222. Sub Form_GotFocus ( )
  223. !   Form1.ForeColor = RGB(128,0,0)A
  224. End SubE
  225. The Immediate
  226. pane is used
  227. to execute singleA
  228. lines of code.N
  229. ile    
  230. dit    
  231. ode    
  232. un    
  233.     indow    
  234. The Default button resets 
  235. the colors of a selected 
  236. object to the default colors A
  237. used in Visual Basic.P
  238. This box shows the current textA(color (text is limited to solid colors).
  239. Open or saveA
  240. a project.
  241. Visual Basic [design]
  242. A     Options \
  243. Or choose the View
  244. Code button to display
  245. the Code window for A
  246. a module or a form.q
  247. ATo make an application respond to user actions or system events, @+you write code for your forms and controls.h
  248. DIn applications with many commands, Visual Basic lets you group your
  249. commands on a 
  250. menu bar@
  251. :You set the properties of forms and controls by using the 
  252. CProperties window.  Properties specify the initial values for such @,characteristics as size, name, and position.^
  253. BThe Visual Basic toolbar provides shortcuts for many common design@
  254. and debugging commands.>
  255. Open the Menu
  256. Design window or theA
  257. Properties window.#
  258. Open a
  259. new formA
  260. or module.B
  261. Sub Form_Load ( )
  262.    Text1.text 
  263. "Colombia" A
  264. End Subs
  265. EVisual Basic provides many tools that you can use to design graphical@)applications. This lesson will introduce:
  266. ClickJ
  267. You write code for 
  268. your applications 
  269. in the Code window.B
  270. Proc:
  271. GotFocus
  272. Object:
  273. Form2
  274. A+A project can also contain custom controls.,
  275. @)You can use forms in many different ways:
  276. Clicking the Options button 
  277. opens a menu of different 
  278. ways to get around in the 
  279. tutorial, as shown inA
  280. the diagram at right.M
  281. Do While
  282. Print
  283.    I 
  284. Project1
  285. Menu Design Window
  286. Properties?
  287. As an illustrated introductionA
  288. screen to an application
  289. Countries of the World"
  290.  Next Statement
  291. dit Watch...
  292. rocedure Step
  293. iA    ngle Step
  294. oggle Breakpoint
  295. How Visual Basic Worksw
  296. -Click the Next button ( > ) to continue.  To 
  297. *return to the Menu or exit Learning VisualA
  298. Basic, click Options.
  299. )Press the PAGE DOWN key to continue with 
  300. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.
  301. Opens this window.-
  302. Jumps to the SummaryA
  303. for that lesson.
  304. Returns to the Menu.!
  305. Closes the Options A
  306. menu.%
  307. Returns to theA
  308. previous step.
  309. OptionsX
  310. +When you're done reading the Instructions, A$click the Close Instructions button.
  311. SettingV
  312. (. . . you can organize your commands on A%a menu bar along the top of the form.k
  313. <To help you review your code quickly, Visual Basic provides:
  314. Automatic syntax checkingd
  315. &Click the Menu button to return to the
  316. +Learning Visual Basic Menu.  To exit, clickA
  317. Options.
  318. Seven data typesz
  319. The Properties window lists 
  320. all the properties and their 
  321. settings for the currently A
  322. selected form or control.(
  323. As a document in A
  324. an applicationL
  325. The Watch pane
  326. displays the current 
  327. values of watch A
  328. expressions.
  329. project
  330. > is the collection of forms, modules, and custom controls that
  331. Fmakes up an application.  The Project window lists all the files in an@
  332. application.8
  333. Closes the tutorial andA
  334. returns to Visual Basic.$
  335. ear All Breakpoints5
  336. A.How to Use the Learning Visual Basic Tutorial 5
  337. A.How to Use the Learning Visual Basic Tutorial 
  338. A    7,269,000
  339. $2,400,000,000
  340. EYou create forms to serve as the interface of your application.  Each@Bform is a window that displays controls, graphics, or other forms.@
  341. [Form1.frm] BackColor: 0A
  342. [Form1.frm] ForeColor: 16776960
  343. @ includes the controls and code associated with that form.  When
  344. Gyou want to share code throughout a project, you can put that code in a
  345. module@
  346. If...Then...Else blocksv
  347.  Pop 
  348.  GNP 
  349.    Income 
  350.  GNP 
  351.    Income 
  352. End If?
  353. As an illustrated introductionA
  354. screen to an application]
  355. &This box shows the current foreground 
  356. %and background colors of the selectedA
  357. object.
  358. Module1.basB
  359.     Form1.frmB
  360. Form1B
  361. nabled
  362. isible
  363. indow List
  364. hecked
  365. To go forward in a lesson,A
  366. click the Next button.  <
  367. To go backward in a lesson,A
  368. click the Back button.  X
  369. (A form file contains the description of A'a form and the code associated with it.
  370. As a dialog boxj
  371. A red arrow  
  372. points to an instruction 
  373. 'for you to follow to continue with the A    tutorial.B
  374. Projects
  375. Forms and controls
  376. Modules_
  377. ,To return to the Learning Visual Basic Menu,A*press the SPACEBAR.  To exit, press ALT+O.
  378. You can display this
  379. window by choosing the
  380. Menu Design command 
  381. from the Window menu or
  382. choosing the Menu DesignA
  383. button on the toolbar..
  384. ile     
  385. dit     
  386. ountry
  387. EBy combining the Visual Basic forms, tools, and programming language,@7you can build powerful applications quickly and easily.<
  388. Start, break, or 
  389. end execution A
  390. of an application.    &Options
  391. View Form
  392. View Code
  393. Cancel
  394. Next Country
  395. Add Country
  396. Edit Country
  397. Insert
  398. Delete
  399. Default
  400. Custom Colors >>
  401. &Back
  402. &Instructions
  403. &Menu
  404.     &Summary
  405. E&xit Tutorial
  406. Cancel: Esc
  407. &Close Instructions
  408. wwwwwwwwp
  409. wwwwwwwwp
  410. wwwww
  411. wwwwwwwwp
  412. wwwwwwwwp
  413. wwwwwwwwwwwwp
  414. wwwwwwwwwwwwp
  415. wwwwwwwwwwwwpwwwwwwwwwwwww
  416. wwwwwwwwwwwwp
  417. wwwwwwwwwwww
  418. wwwwwwwwwwwwpwwwwwwwwwwwww
  419. wwwwwwwwwwwwp
  420. wwwwwwwwwwww
  421. wwwwwwwwwwwwpwwwwwwwwwwwww
  422. wwwwwwwwwwwwp
  423. wwwwwwwwwwww
  424. wwwwwwwwwwwwpwwwwwwwwwwwww
  425. wwwwwwwwwwwwp
  426. wwwwwwwwwwww
  427. wwwwwwwwwwwwpwwwwwwwwwwwww
  428. wwwwwwwwwwwwp
  429. wwwwwwwwwwww
  430. wwwwwwwwwwwwpwwwwwwwwwwwww
  431. wwwwwwwwwwwwp
  432. wwwwwwwwwwww
  433. wwwwwwwwwwwwpwwwwwwwwwwwww
  434. wwwwwwwwwwwwp
  435. wwwwwwwwwwww
  436. wwwwwwwwwwwwpwwwwwwwwwwwww
  437. wwwwwwwwwwwwp
  438. wwwwwwwwwwww
  439. wwwwwwwwwwwwpwwwwwwwwwwwww
  440. wwwwwwwwwwwwp
  441. wwwwwwwwwwww
  442. wwwwwwwp
  443. wwwwwwp
  444. wwwwwwwp
  445. wwwwwwp
  446. wwwwwwwp
  447. wwwwwwp
  448. wwwwwww
  449. wwwwwww
  450. wwwwwwwp
  451. wwwwwww
  452. wwwwwww
  453. wwwwwwp
  454. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  455. wwwwwwwp
  456. wwwwwwp
  457. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  458. wwwwwwwwp
  459. wwwwwwwwp
  460. wwwwwwx
  461. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwp
  462. wwwwwwwwwww
  463. wwwwwwwwwwpwwwwwwwwwww
  464. wwwwwwwwwwp
  465. wwwwwwwwww
  466. wwwwwwwwwwp
  467. wwwwwwwwww
  468. wwwwwwwwwwp
  469. wwwwwww
  470. wwwwwww
  471. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  472. wwwwwwwwwwpwwwwwwwwwww
  473. wwwwwwwwwww
  474. wwwwwwwwwwp
  475. wwwwwwwwwwpwwwwwwwwwww
  476. wwwwwwwwwww
  477. wwwwwwwwwwpwwwwwwwwwww
  478. wwwwwwwwwww
  479. wwwwwwwwwwpwwwwwwwwwww
  480. wwwwwwwwwwpwwwwwwwwwww
  481. wwwwwwwwwwp
  482. wwwwwwwwww
  483. wwwwwwwwww
  484. wwwwwwwwwwp
  485. wwwwwwwwwwp
  486. wwwwwwwwww
  487. wwwwwwwwww
  488. wwwwwwwwwwp
  489. wwwwwwwwww
  490. wwwwwwwwww
  491. wwwwwwwwwwp
  492. wwwwwwwwww
  493. wwwwwwwwwwp
  494. wwwwwwwwww
  495. wwwwp
  496. wwwwww
  497. wwwwwwwwwwwww
  498. wwwwwww
  499. wwwwwww
  500. wwwwwww
  501. wwwwwww
  502. wwwwwww
  503. wwwwwww
  504. wwwwwwwww
  505. wwwwwwwww
  506. wwwwwwwww
  507. wwwwwwwww
  508. wwwwwwwww
  509. wwwwwwwww
  510. wwwwwwwww
  511. wwwwwwwww
  512. wwwwwwwww
  513. wwwwwwwww
  514. wwwwwwwww
  515. wwwwwwwww
  516. wwwwwwwww
  517. wwwwwwwww
  518. wwwwwwwww
  519. wwwwwwwww
  520. wwwwwwwww
  521. wwwwwwwww
  522. wwwwwwwww
  523. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwp
  524. wwwwwwwp
  525. wwwwwww
  526. wwwwwwp
  527. wwwwwww
  528. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  529. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwx
  530. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  531. wwwwwwwp
  532. wwwwwwwp
  533. wwwwwwp
  534. wwwwwwp
  535. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  536. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  537. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwp
  538. wwwwwwwwwwpwwwwwwwwwww
  539. wwwwwwwwwww
  540. wwwwwwwwwwp
  541. wwwwwwwwwwpwwwwwwwwwww
  542. wwwwwwwwwww
  543. wwwwwwwwwwpwwwwwwwwwww
  544. wwwwwwwwwww
  545. wwwwwwwwwwpwwwwwwwwwww
  546. wwwwwwwwwwpwwwwwwwwwww
  547. wwwwwwwwwwp
  548. wwwwwwwwww
  549. wwwwwwwwww
  550. wwwwwwwwwwp
  551. wwwwwwwwwwp
  552. wwwwwwwwww
  553. wwwwwwwwww
  554. wwwwwwwwwwp
  555. wwwwwwwwww
  556. wwwwwwwwww
  557. wwwwwwwwwwp
  558. wwwwwwwwww
  559. wwwwwwwwwwp
  560. wwwwwwwwww
  561. wwwwp
  562. wwwwww
  563. wwwwwwwwwwwwwwwwwwwwwwwwwwwww
  564. wwwwwwwwwwwwwwwwwwwwwwwwwwwww
  565. Clicking the Options button 
  566. opens a menu of different 
  567. ways to get around in the 
  568. tutorial, as shown inA
  569. the diagram at right.
  570. Summary:
  571. BVisual Basic applications, which are event-driven, allow users to 
  572. @control how they enter information.  Visual Basic makes it easy 
  573. Bto create standard applications in the Microsoft Windows operating@
  574. system.
  575. Action
  576. *Button is selected with mouse or keyboard.
  577. !Control is dropped on the button.
  578. #Control is dragged over the button.
  579. Button gets the focus.
  580. *Key is pressed while button has the focus.
  581. ,Key is pressed, and ASCII value is returned.
  582. +Key is released while button has the focus.@
  583. Button loses the focus.T
  584. The event name is the
  585. action that triggers theA
  586. code in the event procedure.\
  587.  cmdChange_Click ( )
  588.     ChangeSignal   
  589. ' Call the procedureA
  590. End Sub
  591. :In a traditional programming environment, users must enter
  592. Ainformation in an order determined by the application programmer.@BFor example, they have to answer the following questions in order.
  593. EA Visual Basic application's interface is made up of objects -- forms
  594. ?and controls.  Each object recognizes actions, such as the user
  595. ?clicking a button, opening a form, or typing in a field.  These
  596. actions are referred to as 
  597. events@
  598. <By clicking the OK button, you've run the code in this event@Bprocedure.  Every time the button is clicked, the code runs again.
  599. DWhen an event occurs in your application, Visual Basic automatically
  600. Brecognizes the event and runs the code that you've written for it.
  601. This code is called an 
  602. event procedure@
  603. >Each form and control in Visual Basic responds to a predefined
  604. <set of events.  For example, a command button recognizes the@
  605. following events.
  606. AFor example, you might want to check the contents of the text box
  607. $when the user chooses the OK button.
  608. @<Clicking the OK button triggers the cmdOKButton_Click event.
  609.  cmdOKButton_Click ( )
  610.  txtState.Text = ''WA'' 
  611.           OrderFormWA.Show
  612.           
  613. OrderFormGeneral.ShowA
  614. End SubI
  615. The object name is the
  616. form or control toA
  617. which you attach code.
  618. Object8
  619. Closes the tutorial andA
  620. returns to Visual Basic.j
  621. A red arrow  
  622. points to an instruction 
  623. 'for you to follow to continue with the A    tutorial.
  624. Event procedures can also:
  625. Trigger other event procedures.
  626. Change an object's properties.
  627.  @=Call other general procedures that are not tied to any event.F
  628. )Press ENTER or click the OK button to runA
  629. the event procedure.v
  630. Event procedures can also:
  631. Trigger other event procedures.
  632. Change an object's properties.
  633. EAn event procedure runs only when the event occurs, and Visual Basic 
  634. Oremains idle until that happens.  You can see how this works for the OK button.
  635. Click the OK button or press 
  636. ENTER@
  637. Event
  638. Click
  639. DragDrop
  640. DragOver
  641. GotFocus
  642. KeyDown
  643. KeyPress
  644. KeyUp@    LostFocus
  645. Personnel Information
  646. Address:
  647. Name:
  648. City:
  649. State:
  650. Project1    
  651. Enter your name >  Joe Smith
  652. #Enter your address > 555 Cedar LaneA
  653. Enter your city >_
  654. A    Joe Smith
  655. 98555
  656. Redmond
  657. Controls 
  658. TextA
  659.  = '' '' Then
  660. Sub cmdOKButton_Click ( )
  661.      If txtName.Text = '' '' Then
  662. $         MsgBox ''Enter your name.''
  663.     End IfB
  664. End Sub
  665. Sub cmdOKButton_Click ( )
  666.      If txtName.Text = '' '' Then
  667. $         MsgBox ''Enter your name.''
  668. End IfA
  669. End Sub
  670. Sub cmdOKButton_Click ( )
  671.      If txtName.Text = '' '' Then
  672.              
  673. MsgBox
  674.  ''Enter your name.''
  675.     End IfA
  676. End Sub
  677. Sub cmdOKButton_Click ( )
  678.  txtName.Text 
  679.  '' '' 
  680. $         MsgBox ''Enter your name.''
  681.     End IfA
  682. End Sub
  683. =You need to write code only for the events that you want your
  684. application to respond to.
  685. DTo determine which events to write code for, you need to think about@?what the user will do, and how you want the program to respond.
  686. >Event procedure names combine the control name, an underscore,
  687. 8and the event name.  So the event procedure name for the
  688. "cmdOKButton's Click event would be
  689. cmdOKButton_Click.
  690. AAn event procedure name is made up of an object name and an event
  691. Gname.  The object name for all forms is Form.  For controls, the object
  692. @name is the control's Name property.   There can be one or more @!statements in an event procedure.
  693. "This lesson will introduce you to:
  694. Event-driven programming
  695. Event procedures
  696.   o @
  697. Syntax for eventsw
  698. -Click the Next button ( > ) to continue.  To 
  699. *return to the Menu or exit Learning VisualA
  700. Basic, click Options.
  701. Opens this window.-
  702. Jumps to the SummaryA
  703. for that lesson.
  704. Returns to the Menu.!
  705. Closes the Options A
  706. menu.%
  707. Returns to theA
  708. previous step.
  709. OptionsX
  710. +When you're done reading the Instructions, A$click the Close Instructions button.O
  711. Event procedures can also:
  712. Trigger other event procedures.
  713. This lesson covered:
  714. Event-driven programming
  715. Event procedures
  716. Syntax for events
  717. %For more information on event-driven 
  718. programming, see the lesson
  719. -''Debugging Your Application'' or Chapter 6, 
  720. $''Programming Fundamentals,'' in theC
  721. Programmer's Guide.
  722.  chkBold_Click ( )
  723.   If 
  724. chkBold.Value = 1 
  725. Then 
  726.      
  727.         txtDisplay.FontBold = 
  728. End IfA
  729. End Subd
  730. &Click the Menu button to return to the
  731. +Learning Visual Basic Menu.  To exit, clickA
  732. Options.B
  733.  cmdDelete_Click ( )
  734.     mnuDelete_ClickA
  735. End Sub
  736. :Visual Basic is a programming system that you use to write
  737. event-driven applications
  738. (.  Programming in response to particular
  739. Fevents, such as a key press or a mouse click, makes it easy to create @;applications that are visually appealing and simple to use.
  740. Period
  741. cmdOKButtonv
  742.  If txtName.Text = '' '' Then
  743. $         MsgBox ''Enter your name.''
  744.     End IfA
  745. End Sub
  746. Click B
  747. txtName
  748. Sub cmdOKButton_Click ( )
  749.     If 
  750. $         MsgBox ''Enter your name.''
  751.     End IfA
  752. End Sub5
  753. A.How to Use the Learning Visual Basic Tutorial 5
  754. A.How to Use the Learning Visual Basic Tutorial 
  755. Sub cmdOKButton_Click ( )
  756.     If 
  757. txtName.Text
  758.  = '' '' Then
  759. $         MsgBox ''Enter your name.''
  760.     End IfA
  761. End Sub
  762.  cmdOKButton_Click 
  763.      If txtName.Text = '' '' Then
  764. $         MsgBox ''Enter your name.''
  765.     End IfC
  766. End Sub
  767.  cmdOKButton_Click 
  768.  txtName.Text 
  769.  '' '' 
  770.              
  771. MsgBox
  772.  ''Enter your name.''
  773. End IfA
  774. End Sub
  775. ;You refer to a control and its properties in code using the
  776. Eobject.property notation.  For example, to refer to text displayed in@,a text box, the syntax would look like this:
  777. Enter your name.
  778. Property"
  779. cmdOKButton_Click B
  780. Statements are the
  781. code you want to runA
  782. when the event occurs.
  783. Name;
  784. To go forward in a lesson,A
  785. click the Next button.  <
  786. To go backward in a lesson,A
  787. click the Back button.  $
  788. Writing Event-Driven Programs
  789. Underscore
  790. Event_
  791. ,To return to the Learning Visual Basic Menu,A*press the SPACEBAR.  To exit, press ALT+O.
  792. )Press the PAGE DOWN key to continue with 
  793. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.
  794. Form    &Options
  795. &Back
  796. &Instructions
  797. &Menu
  798.     &Summary
  799. E&xit Tutorial
  800. Cancel: Esc
  801. &Close Instructions
  802. Summary:
  803. 2. Set properties
  804. You set the properties of a
  805. !control in the Properties window.
  806. #When you select a form or control, 
  807. "its properties and their settings 
  808.  are displayed in the Properties @
  809. window.
  810. Form1
  811. Creating an Application
  812. Every new project contains one
  813. form.  You can add as many
  814. additional forms as your
  815. application needs.
  816. The Temperature Conversion
  817. application requires only one@
  818. form.
  819. Form1
  820. Celsius:
  821. Fahrenheit:+
  822. Code that controls A
  823. the application
  824. KeyPressh
  825. *Sub txtCels_KeyPress (KeyAscii As Integer)
  826. ,    txtFahr.Text = 9/5 * (txtCels.Text) + 32A
  827. End Sub
  828. project 
  829.     includes:
  830. Forms -- backgrounds,  
  831. windows, and dialog boxes.
  832. Controls -- graphical objects 
  833. placed on forms.
  834. procedures and 
  835.     @
  836. declarations.
  837. Proc:
  838. Object:6
  839. Text boxes for 
  840. entering and A
  841. displaying text
  842. A form
  843. $There are three steps to creating an
  844. application:
  845. Create the interface.
  846. Set properties.
  847. Write code.
  848. 3. Write code
  849. To make the application respond
  850. "to the user's actions, we'll write
  851. event procedures for the text 
  852. boxes. 
  853. These event procedures are @
  854. triggered by a KeyPress event.
  855. This form is the background of
  856. the application.
  857. We can change the size and
  858. location of the form to fit the@
  859. application's design.{
  860. .Type a number in the text box, and then press 
  861. ,ENTER.  To continue with the tutorial, clickA
  862. the Next ( > ) button.
  863.  Next, we'll select the tools we 
  864. need from the Toolbox to draw
  865. !the controls we want on the form.
  866. In this application, text boxes
  867. accept user input and display
  868. text.@
  869.  We'll create two text boxes, one
  870.  for Fahrenheit temperatures and 
  871. one for Celsius temperatures.
  872. When the user enters a
  873. temperature in one of the text
  874. "boxes, the equivalent temperature @#is displayed in the other text box.`
  875. The pieces of the application
  876. are now in place.  To make it @
  877. work, we need to add the code.b
  878. Once you save a project, you
  879. can go back and change its
  880. appearance or operation at any@
  881. time.i
  882.  To describe the contents of each
  883. text box, we'll use labels.
  884. Labels can't be changed by the@
  885. user.
  886. #We'll use the following formulas to
  887. convert the temperatures:
  888.      Cels = (Fahr - 32) * 5/9
  889.      Fahr = (Cels * 9/5) + 32
  890. "Next, we'll enter the code for the@
  891. event procedure.
  892. The Procedure list box contains
  893. !a list of events for the control.
  894. "Selecting the KeyPress event from 
  895. $the Procedure list box displays the 
  896. !template for the event procedure @
  897. we want to write.
  898. Now, we'll change the Name 
  899. property of the other text
  900. box to txtFahr and the Caption 
  901. property of its label to @
  902. Fahrenheit.E
  903.  Now we'll attach a similar event@ procedure to the other text box.
  904. To try out the application:
  905. Type values in the text box,
  906.       and press 
  907. ENTER
  908.  to convert @
  909.       the temperature.
  910. When you finish working on your
  911.  application, you'll want to save
  912. the project.
  913. Choosing Save Project from the 
  914. File menu prompts you to assign@
  915. a name to the project.#
  916. @ The application is now complete.
  917.  You can test your application by
  918.  choosing Start from the Run menu
  919. or clicking the Start button ( 
  920. the toolbar.
  921. You can also use the debugging 
  922. tools to help locate and fix @
  923. problems in your application.
  924. (This lesson demonstrated how to create a
  925. simple application:
  926.    1.  Create the interface.
  927.    2.  Set properties.
  928.    3.  Write code.
  929. /The lessons that follow explain the parts of a @(Visual Basic application in more detail.
  930. Enter a temperature:M
  931. :As you run your application, you might also think of ways @
  932. to improve it.
  933. %Provide a graphical way to enter and A+display the temperatures using scroll bars.R
  934. %Add a command button that clears the A$temperatures from both text boxes.  
  935.  When your application is exactly
  936. the way you want it, you can
  937.  make it into an executable file.
  938. !This allows you, and other users,
  939. #to run the application outside the @
  940. Visual Basic environment.
  941. Celsius:
  942. Fahrenheit:
  943. When the user types a
  944. temperature in one of the text
  945. boxes and presses 
  946. ENTER
  947. , the
  948. !code updates the contents of the @
  949. other text box.w
  950. -Click the Next button ( > ) to continue.  To 
  951. *return to the Menu or exit Learning VisualA
  952. Basic, click Options.j
  953. ,Click the Menu button ( > ) to return to the
  954. +Learning Visual Basic Menu.  To exit, clickA
  955. Options.
  956. Opens this window.-
  957. Jumps to the SummaryA
  958. for that lesson.
  959. Returns to the Menu.!
  960. Closes the Options A
  961. menu.%
  962. Returns to theA
  963. previous step.
  964. OptionsX
  965. +When you're done reading the Instructions, A$click the Close Instructions button.h
  966. Assist the user by providing 
  967. &instructions and checking for invalid A
  968. entries in the text boxes.
  969. CThis lesson demonstrates how to build a Visual Basic application.  
  970. @EThe application converts temperatures between Fahrenheit and Celsius.
  971. 1.  Create the interface
  972. To create an application, you 
  973. !first need to open a new project.
  974. You open a project by choosing
  975. the New Project command from@
  976. the File menu.
  977. The Caption property specifies
  978. !the text that is displayed in the
  979. #control.  We'll change the label's @
  980. Caption property to Celsius.5
  981. A.How to Use the Learning Visual Basic Tutorial 5
  982. A.How to Use the Learning Visual Basic Tutorial k
  983. To create an executable file
  984. from your project, you use the
  985. Make EXE File command from@
  986. the File menu.
  987. %To create a control, select the tool 
  988. from the Toolbox, and then hold
  989.  down the left mouse button while
  990. !dragging out an area on the form.
  991.  You can create a control in the 
  992.  default size by double-clicking 
  993. !the tool or selecting a tool and 
  994.     pressing 
  995. ENTER@
  996. Labels
  997. )You can't go back from this point in the 
  998. %lesson.  To review the lesson, chooseA&Creating an Application from the Menu.;
  999. To go forward in a lesson,A
  1000. click the Next button.  <
  1001. To go backward in a lesson,A
  1002. click the Back button.  
  1003. Clicking the Options button 
  1004. opens a menu of different 
  1005. ways to get around in the 
  1006. tutorial, as shown inA
  1007. the diagram at right.8
  1008. Closes the tutorial andA
  1009. returns to Visual Basic.j
  1010. A red arrow  
  1011. points to an instruction 
  1012. 'for you to follow to continue with the A    tutorial.E
  1013. @BThe Temperature Conversion application consists of these elements:_
  1014. ,To return to the Learning Visual Basic Menu,A*press the SPACEBAR.  To exit, press ALT+O.
  1015. )Press the PAGE DOWN key to continue with 
  1016. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.~
  1017. You use the Name property to 
  1018. %refer to a control in code.  In this 
  1019. case, we'll make txtCels the @
  1020. name of this text box.
  1021.  When you double-click a control,
  1022. the focus shifts to the Code 
  1023. window.  The code template for 
  1024. the selected control's default 
  1025. event procedure is displayed.
  1026.  The name of the control appears @
  1027. in the Object list box.    &Options
  1028. &Menu
  1029. Update
  1030. txtCels
  1031. Celsius:
  1032. txtFahr
  1033. Endif
  1034. Fahrenheit:
  1035. &Back
  1036. &Instructions
  1037.     &Summary
  1038. E&xit Tutorial
  1039. Cancel: Esc
  1040. 'txtCels.Text = Val(txtFahr.Text-32)*5/9.If (KeyAscii=13)Then ' keyascii 13 = Enter key-txtFahr.Text = 9 / 5 * Val(txtCels.Text) + 32,
  1041. &Close Instructions
  1042. z    [    z    
  1043. n    ,    -
  1044. wwwwwww
  1045. wwwwwww
  1046. wwwwwww
  1047. wwwwwww
  1048. One minute....
  1049. ...files are being loaded.
  1050.  After you enter the caption and 
  1051. name, you can click the Next 
  1052. button or press 
  1053. ENTER
  1054.  to create 
  1055. the File menu control.
  1056. "The highlight then moves to a new 
  1057. #line, and the text boxes are reset 
  1058. to accept the next caption and @
  1059. name.
  1060. ountryi
  1061. =Menus consist of menu titles, menu items, and separator bars.@'Every part of a menu is a menu control.
  1062. Separator bar
  1063. A    Menu item
  1064. ountry
  1065. Sweden
  1066. Menu title
  1067. Population
  1068. Income per Capita
  1069. $A menu is a control, like a text box
  1070. !or a command button.  Like other 
  1071. !controls, a menu has a predefined@
  1072. set of properties and events.
  1073. To distinguish menu items from
  1074.  menu titles, you indent the menu
  1075. !items in the lower portion of the
  1076. Menu Design window.
  1077.  To indent a menu item, select it
  1078. and then click the right arrow @
  1079. button.
  1080. Create the File menu
  1081. "The text you enter in the Caption 
  1082. text box defines the menu name.
  1083. !This is the text that appears on 
  1084. the menu bar.@
  1085.  The text in the Name box defines
  1086. the menu's Name property.  This
  1087. !is used to refer to the File menu@
  1088. in code.
  1089. In addition, you can set other
  1090. menu properties in the Menu
  1091. Design window.
  1092. After you have created a menu,
  1093. you can change its property
  1094. "settings in either the Menu Design@ window or the Properties window.
  1095. specifies a menu title, such 
  1096. "   as File or Edit, or an item on 
  1097.    a menu, such as Open or Cut.
  1098.  the name used to refer to the 
  1099.    menu control in code.
  1100. a numeric value that uniquely 
  1101. %   identifies the menu control if it A
  1102.    is part of a control array.q
  1103. .You use the Menu Design window to create menu 
  1104. "controls and set their properties:
  1105. Caption@
  1106. .You use the Menu Design window to create menu 
  1107. "controls and set their properties:
  1108. Caption
  1109. Index
  1110. ext Country
  1111. The File menu now consists of
  1112. one command -- Exit.
  1113.  Next, we'll add the second menu 
  1114. !to the menu bar -- Country -- and
  1115. a command to the Country @
  1116. menu -- Next Country. 
  1117. ind...
  1118. Inserting an ampersand (&) 
  1119. before a letter gives the user 
  1120. keyboard access to the menu.
  1121.  At run time, this letter will be
  1122. underlined.
  1123. "For example, in this menu the user
  1124. could select the File menu by 
  1125.     pressing A
  1126. ALT+F.
  1127. Adding Menus
  1128. Opens this window.-
  1129. Jumps to the SummaryA
  1130. for that lesson.
  1131. Returns to the Menu.!
  1132. Closes the Options A
  1133. menu.%
  1134. Returns to theA
  1135. previous step.
  1136. OptionsX
  1137. +When you're done reading the Instructions, A$click the Close Instructions button.w
  1138. -Click the Next button ( > ) to continue.  To 
  1139. *return to the Menu or exit Learning VisualA
  1140. Basic, click Options.
  1141. Open the Menu Design window
  1142. You use the Menu Design window 
  1143. to create menus for your form.
  1144.  Switch to the form to which you 
  1145. want to add a menu, and then @
  1146. open the Menu Design window. 
  1147. GThis lesson will demonstrate how to create menus in Visual Basic using 
  1148. 'the Countries of the World application.
  1149. DThis application has two menus on its menu bar:  File and Country.  @CThe commands on the menus remain hidden until the menu is selected.
  1150. revious Country
  1151. eA    w Country5
  1152. A.How to Use the Learning Visual Basic Tutorial 
  1153. This lesson covers:
  1154. The Menu Design window
  1155. Menus and menu commands
  1156. Menu design guidelines5
  1157. A.How to Use the Learning Visual Basic Tutorial 
  1158. Add the Exit menu command
  1159. To add the Exit command to the
  1160. File menu, we'll enter E&xit in
  1161. the Caption box.
  1162. In the Name box, we'll enter
  1163.  mnuFileExit to refer to the Exit@
  1164. command in code.
  1165. (The example files needed for this lesson
  1166. )cannot be found.  To run this lesson, youA(need to reinstall Learning Visual Basic.;
  1167. To go forward in a lesson,A
  1168. click the Next button.  <
  1169. To go backward in a lesson,A
  1170. click the Back button.  
  1171. Clicking the Options button 
  1172. opens a menu of different 
  1173. ways to get around in the 
  1174. tutorial, as shown inA
  1175. the diagram at right.8
  1176. Closes the tutorial andA
  1177. returns to Visual Basic.j
  1178. A red arrow  
  1179. points to an instruction 
  1180. 'for you to follow to continue with the A    tutorial.
  1181. )Press the PAGE DOWN key to continue with 
  1182. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.
  1183. .You use the Menu Design window to create menu 
  1184. "controls and set their properties:
  1185. Caption
  1186. specifies a menu title, such 
  1187. "   as File or Edit, or an item on 
  1188.    a menu, such as Open or Cut.
  1189. the name used to refer to the A
  1190.    menu control in code.w
  1191. specifies a menu title, such 
  1192. "   as File or Edit, or an item on A
  1193.    a menu, such as Open or Cut.
  1194. You open the Menu Design
  1195. window by choosing the Menu
  1196. Design command from the 
  1197. Window menu or choosing the 
  1198. Menu Design button from the@
  1199. toolbar.    &Options
  1200. &File
  1201. mnuFile
  1202. mnuFileExit
  1203. &Back
  1204. &Instructions
  1205. &Menu
  1206.     &Summary
  1207. E&xit Tutorial
  1208. Cancel: Esc
  1209. E&xit
  1210. sweden.frm
  1211. Return to &Menu
  1212. E&xit Learning VB
  1213. country.mak,
  1214. &Close Instructions
  1215. Summary:
  1216. Select mnuFileExit from the 
  1217. Object box
  1218. We entered mnuFileExit as the 
  1219. Exit command's Name property.
  1220. The Name property is used@
  1221. to refer to a control in code.
  1222. Write the code
  1223. We'll write code to make the
  1224.  application respond to the Exit 
  1225. command.  The code goes
  1226. between the Sub and End Sub 
  1227. statements in the Code window.@
  1228. The code we entered ends the @#Countries of the World application.
  1229. Separator A
  1230. New...
  1231. Open...
  1232. Close the Menu Design window
  1233. When you close the Menu
  1234. Design window, the menus are
  1235. automatically displayed on the@
  1236. form.
  1237. BWhen creating menus, follow these standard menu design guidelines:
  1238. )Group related commands on a menu in a way
  1239. 2that will make sense to users of your application.
  1240. +For example, users familiar with Microsoft 
  1241. *Windows may expect to find the New, Open, 
  1242. /and Close commands together on the File menu.  
  1243. ,Look at existing Windows-based applications 
  1244. for examples.
  1245. *On long menus, separate groups of related 
  1246. *commands with a separator bar.  Separator 
  1247. .bars are created by using a single hyphen (-) 
  1248.    @-in the Caption box of the Menu Design window.
  1249. Adding Menus
  1250. Opens this window.-
  1251. Jumps to the SummaryA
  1252. for that lesson.
  1253. Returns to the Menu.!
  1254. Closes the Options A
  1255. menu.%
  1256. Returns to theA
  1257. previous step.
  1258. OptionsX
  1259. +When you're done reading the Instructions, A$click the Close Instructions button.w
  1260. -Click the Next button ( > ) to continue.  To 
  1261. *return to the Menu or exit Learning VisualA
  1262. Basic, click Options.d
  1263. &Click the Menu button to return to the
  1264. +Learning Visual Basic Menu.  To exit, clickA
  1265. Options.
  1266. When the user clicks a menu 
  1267. "title, Visual Basic automatically 
  1268. displays its menu.
  1269. To define how each menu
  1270. command responds to a Click
  1271. event, you write an event@
  1272. procedure for each command.
  1273. Close
  1274. Save As...5
  1275. A.How to Use the Learning Visual Basic Tutorial 5
  1276. A.How to Use the Learning Visual Basic Tutorial 
  1277. Menu commands respond only 
  1278. #to Click events.  If a user selects
  1279.  a menu item when the application
  1280. !is running, the associated Click @
  1281. event procedure is executed.;
  1282. To go forward in a lesson,A
  1283. click the Next button.  <
  1284. To go backward in a lesson,A
  1285. click the Back button.  t
  1286. )You can't go back from this point in the 
  1287. %lesson.  To review the lesson, chooseA
  1288. Adding Menus from the Menu.
  1289. Clicking the Options button 
  1290. opens a menu of different 
  1291. ways to get around in the 
  1292. tutorial, as shown inA
  1293. the diagram at right.8
  1294. Closes the tutorial andA
  1295. returns to Visual Basic.j
  1296. A red arrow  
  1297. points to an instruction 
  1298. 'for you to follow to continue with the A    tutorial.
  1299. Open the Code window
  1300. "You write event procedures in the 
  1301. Code window.
  1302. To open the Code window for a
  1303. form, choose View Code from the
  1304. Code menu, or press
  1305. %This lesson showed you how to create 
  1306. )menus for your Visual Basic applications 
  1307. using the Menu Design window.  
  1308. 'For more information on creating menus,
  1309. &see Chapter 4, ''Menus and Dialogs,'' 
  1310. in theA
  1311.  Programmer's Guide._
  1312. ,To return to the Learning Visual Basic Menu,A*press the SPACEBAR.  To exit, press ALT+O.
  1313. )Press the PAGE DOWN key to continue with 
  1314. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.    &Options
  1315. &Country
  1316. mnuCountry
  1317. &Next Country
  1318. mnuCountryNextCountry
  1319. &Back
  1320. &Instructions
  1321. &Menu
  1322.     &Summary
  1323. E&xit Tutorial
  1324. Cancel: Esc
  1325. &Close Instructions
  1326. You can create
  1327. color schemes
  1328. that match 
  1329. your company'sA
  1330. logo.
  1331. Catalog
  1332. Summary:
  1333. Product Order Form
  1334. A    Inventory    
  1335. Search
  1336. Enter Item Number:
  1337. Border Lakes Real Estate
  1338. Index
  1339.  Property Type D
  1340. @AYou set the color properties of objects in the Properties window.
  1341. Product Sales
  1342. Specifications
  1343. A    Item No. 
  1344. Bronze
  1345. Units Sold
  1346. 8,200
  1347. Units Returned
  1348. 21,500
  1349. Net Unit Sales
  1350. -13,300
  1351. The property that 
  1352. you're setting.  
  1353. Properties that
  1354. use colors include 
  1355. BackColor,
  1356. ForeColor,
  1357. BorderColor, and A
  1358. FillColor.
  1359. Item No.
  1360. Diametery
  1361. BYou can define your own colors and add them to the Color palette. 
  1362. @0You can have up to 16 custom colors at one time.V
  1363. >Similarly, you can use different colors to identify different @
  1364. sections of a form.
  1365. Units EachH
  1366. Visual Basic saves your
  1367. custom colors from sessionA
  1368. to session. *
  1369. Please answer all A
  1370.      questions.
  1371. Product Ordering
  1372. Properties
  1373. Buyers
  1374. Opens this window.-
  1375. Jumps to the SummaryA
  1376. for that lesson.
  1377. Returns to the Menu.!
  1378. Closes the Options A
  1379. menu.    
  1380. Sellers
  1381. 0.375"+
  1382. A frame can containA
  1383. other controls.X
  1384. A picture box or an image
  1385. control can display a bitmap,A
  1386. an icon, or a metafile.D
  1387. Use white to show the fieldsA
  1388. in which you enter information.
  1389. Quantity
  1390. A    Cost Each
  1391. Total1
  1392. Use yellow to showA
  1393. the calculated fields.
  1394. )Press the PAGE DOWN key to continue with 
  1395. 'this lesson.  To choose another part ofA.Learning Visual Basic or to exit, press ALT+O.
  1396. Bin No.
  1397. Length
  1398. HEX7782A
  1399. 150,500
  1400. Auditor
  1401. Log No.
  1402. Wyatt
  1403. 5/4/91
  1404. WA-5B-91>
  1405. The blue section shows A
  1406. information about the product.:
  1407. The red section showsA
  1408. information about the audit.
  1409. =As you design your forms, try to avoid using too many colors.
  1410. >You'll have better results if you pick one group of colors and@
  1411. stick to them.
  1412. Production Outline
  1413. Length
  1414. Diameter
  1415. HEX7782A
  1416. Material
  1417. 1.25"
  1418. Material
  1419.  Price Range 
  1420. Item No.
  1421. CYou can also use Visual Basic code to change the color of an object
  1422. 0while your application is running.  For example:
  1423. <You can change the color of a field as soon as a user moves 
  1424. to that field.K
  1425. (In this form, one color is used for the A
  1426. background for all fields.
  1427. 1.25"
  1428. 0.375"    
  1429. Clicking the Options button 
  1430. opens a menu of different 
  1431. ways to get around in the 
  1432. tutorial, as shown inA
  1433. the diagram at right.
  1434. Bronzep
  1435. )Here, a different color is used for each 
  1436. 'field.  Notice how the form appears tooA
  1437. busy and distracting.
  1438. ?When designing applications that rely extensively on color, you
  1439. @may find it helpful to use a color guide or work with a designer@3to make the best use of color in your applications.
  1440. Buyer Survey
  1441. Community:
  1442. Residential Properties
  1443.     CondominiumM
  1444. A very small application
  1445.          created in A
  1446.      Visual Basic 2.0.
  1447. &This lesson discussed using color and 
  1448. +graphics in your Visual Basic applications.
  1449. %For more information on graphics, see
  1450. #Chapter 15, ''Creating Graphics for
  1451. Applications,'' in the
  1452.  Programmer's Guide.
  1453.     Undeveloped Land
  1454. A        House
  1455. AUsing color and graphics effectively is an art.  In the following
  1456. ?screens, we offer some basic tips on the different ways you can@
  1457. enhance your applications.m
  1458. =You can design custom command buttons for a form by attaching@+code to an image control or a picture box. 
  1459. John and Jane Homebuyer
  1460. Border Lakes
  1461. $50,000
  1462. Border Lakes
  1463.  txtSales_Change 
  1464.     If
  1465. txtSales.Text < 0 
  1466.         txtSales.ForeColor =
  1467.  RGB(
  1468. 255,0,0
  1469.     Else
  1470.         txtSales.ForeColor = 
  1471. 0,0,0
  1472.     End If
  1473. End Subt
  1474. This application 
  1475. displays a message 
  1476. and draws a box around 
  1477. a field if a user leaves A
  1478. that field empty.
  1479. Client Name:D
  1480. The Visual Basic language
  1481. can be used to draw otherA
  1482. shapes.R
  1483. MWith Visual Basic, you can easily add color and graphics to an application.  @
  1484. Product SalesO
  1485. >You can use Visual Basic code to display graphics in response @
  1486. to an event.
  1487. PAN3352AI
  1488. Lines and shapes can be
  1489. added to forms toA
  1490. emphasize information.5
  1491. You can create
  1492. arcs using theA
  1493. Circle method.G
  1494. You can create temporary
  1495. visual effects with the A
  1496. Line method.+
  1497. The object that A
  1498. you're working on.j
  1499. CAdding color to your forms and controls can make your applications @"more attractive and easier to use.A
  1500. You can use colors to 
  1501. emphasize important A
  1502. information.<
  1503. You choose a color fromA
  1504. the drop-down Color palette.
  1505. Using Color and Graphics
  1506. Form1 B
  1507. A    DrawWidth
  1508. A    BackColor
  1509. BorderStyle
  1510. Caption
  1511. ClipControls
  1512. ControlBox
  1513. DrawMode
  1514. A    DrawStyle
  1515. &H000040C0&
  1516. 2 - Sizable
  1517. Form1
  1518. 13 - Copy Pen
  1519. A    0 - Solid
  1520. Properties%
  1521. Returns to theA
  1522. previous step.
  1523. OptionsX
  1524. +When you're done reading the Instructions, A$click the Close Instructions button.w
  1525. -Click the Next button ( > ) to continue.  To 
  1526. *return to the Menu or exit Learning VisualA
  1527. Basic, click Options.
  1528. JGraphics methods in the Visual Basic language also let you create graphics
  1529. Hin your application.  Creating graphics with graphics methods is done in
  1530. Fcode, so these images appear on your form only when the application is@
  1531. running.b
  1532. 5You can make your forms easier to use by applying the@(same color to similar types of fields.  5
  1533. A.How to Use the Learning Visual Basic Tutorial 8
  1534. Closes the tutorial andA
  1535. returns to Visual Basic.5
  1536. A.How to Use the Learning Visual Basic Tutorial \
  1537.  txtItemNo_GotFocus 
  1538.      
  1539. txtItemNo.BackColor = &HFFFF&A
  1540. End Sub
  1541. CYou can also use Visual Basic code to change the color of an object
  1542. 0while your application is running.  For example:
  1543. <You can change the color of a field as soon as a user moves 
  1544. to that field.
  1545. <You can control the color of a value, depending upon whether
  1546.    @#that value is positive or negative.
  1547. Threads/in.
  1548. Each button on this form is 
  1549. an image control.  When a 
  1550. user clicks a picture, 
  1551. Visual Basic runs the code A
  1552. attached to that control.d
  1553. The Define Colors button 
  1554. displays a dialog box 
  1555. that allows you to select A
  1556. custom colors.
  1557. Johnson
  1558. Nut and Bolt, Inc.%
  1559. Product CatalogA
  1560. January, 1993;
  1561. To go forward in a lesson,A
  1562. click the Next button.  <
  1563. To go backward in a lesson,A
  1564. click the Back button.  O
  1565. @LGraphics can increase the usefulness of and add visual impact to your forms.
  1566. This lesson covers:
  1567. Using graphics
  1568. Using colors
  1569. &Changing graphics and colors with code
  1570.  @(Designing forms with graphics and colorsj
  1571. A red arrow  
  1572. points to an instruction 
  1573. 'for you to follow to continue with the A    tutorial.
  1574. About this Application    &Options
  1575. &Menu
  1576. Default
  1577. Custom Colors >>
  1578. Define Colors...
  1579. Search
  1580. Index
  1581. &Back
  1582. &Instructions
  1583.     &Summary
  1584. E&xit Tutorial
  1585. Cancel: Esc
  1586. &Close Instructions
  1587. p    u    p    
  1588. wwwwwwwwpwwwwwwwww
  1589. wwwwwwwwp
  1590. wwwwwwww
  1591. wwwwwwwwwwwwwwwwwwwwwwww
  1592. wwwwwwwwwwwwwwwwwwwwwwww
  1593. wwwwwwwwwwwwwwwwwwwwwwww
  1594. wwwwwwwwwwwwwwwwwwwwwwww
  1595. wwwwwwwwwwwwwwwwwwwwwwww
  1596. wwwwwwwwwwwwwwwwwwwwwwww
  1597. ;;;30
  1598. wwwwwwwp
  1599. wwwwwwp
  1600. wwwwwwwp
  1601. wwwwwwp
  1602. wwwwwwwp
  1603. wwwwwwp
  1604. wwwwwww
  1605. wwwwwww
  1606. wwwwwwwp
  1607. wwwwwww
  1608. wwwwwww
  1609. wwwwwwp
  1610. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  1611. wwwwwwwp
  1612. wwwwwwp
  1613. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  1614. wwwwwwwwp
  1615. wwwwwwwwp
  1616. wwwwwwx
  1617.